package com.wwj.shiro;


import com.wwj.core.system.entity.User;
import org.apache.commons.lang3.builder.HashCodeBuilder;

import java.io.Serializable;


public class ShiroUser implements Serializable {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    /**
     * 编号
     */
    private String id;
    /**
     * 姓名
     */
    private String name;
    /**
     * 用户类型
     */
    private Integer type;
    /**
     * 账号
     */
    private String account;

    /**
     * 邮箱
     */
    private String email;

    private Integer barId;

    private String barName;

    public ShiroUser() {

    }

    public ShiroUser(User user) {
        this.id = user.getId();
        this.account = user.getAccount();
        this.name = user.getName();
        this.type = user.getType();
    }



    /**
     * 本函数输出将作为默认的<shiro:principal/>输出.
     */
    @Override
    public String toString() {
        return this.account;
    }

    /**
     * 重载equals,只计算account;
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        ShiroUser other = (ShiroUser) obj;
        if (account == null) {
            if (other.account != null)
                return false;
        } else if (!account.equals(other.account))
            return false;
        return true;
    }

    public int hashCode() {
        return new HashCodeBuilder()
                .append(getAccount())
                .toHashCode();
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }


    public void setName(String name) {
        this.name = name;
    }


    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public Integer getBarId() {
        return barId;
    }

    public void setBarId(Integer barId) {
        this.barId = barId;
    }

    public String getBarName() {
        return barName;
    }

}